/* GUI CONVERTED from rcpccal1.p (converter v1.76) Sun Sep 23 23:24:15 2001 */
/* rcpccal1.p - Release Management Customer Schedules                         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* Revision: $                                                                */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3    LAST MODIFIED: 11/11/94   BY: dpm *GO13*                  */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan           */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown           */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.3.1.2      BY: Jean Miller        DATE: 03/22/01  ECO: *P008*  */
/* Revision: $            BY: Hareesh V          DATE: 08/06/01  ECO: *M1GV*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/******************************************************************
 * This subroutine looks for a price list match based on sales
 * order information using the following hierarchy:
 *    1) matching item, um, currency, effective date;
 *    2)  price list, currency, effective date, item;
 *    3)  price list, currency, effective date, product line, um;
 *    4)  price list, currency, effective date, product line;
 *    5)  price list, currency, effective date, um;
 *    6)  price list, currency, effective date.
 * NOTE: This file is related to subroutines *pccal*.p; changes
 *       made to this routine should likely be made there as well.
 *******************************************************************/

define input parameter part     as character.
define input parameter pr_list  as character.
define input parameter eff_date as date.
define input parameter um       as character.
define input parameter curr     as character.
define output parameter found   like mfc_logical.

find pt_mstr where pt_part = part no-lock no-error.

found = no.

find last pc_mstr where
          pc_list = pr_list
      and trim(pc_prod_line) = ""
      and pc_part = part
      and pc_um = um
      and (pc_start <= eff_date or pc_start = ?)
      and (pc_expire >= eff_date or pc_expire = ?)
      and pc_curr = curr
no-lock no-error.

/* FIND PRICE LIST FOR PART REGARDLESS OF UM */
if not available pc_mstr
then
   find last pc_mstr where
          pc_list = pr_list
      and pc_part = part
      and trim(pc_um) = ""
      and (pc_start <= eff_date or pc_start = ?)
      and (pc_expire >= eff_date or pc_expire = ?)
      and pc_curr = curr
   no-lock no-error.

/* FIND PRICE LIST FOR PRODUCT LINE AND UM */
if not available pc_mstr and available pt_mstr
then
   find last pc_mstr where
          pc_list = pr_list
      and trim(pc_part) = ""
      and pc_prod_line = pt_prod_line
      and pc_um = um
      and (pc_start <= eff_date or pc_start = ?)
      and (pc_expire >= eff_date or pc_expire = ?)
      and pc_curr = curr
   no-lock no-error.

/* FIND PRICE LIST FOR PRODUCT LINE REGARDLESS OF UM */
if not available pc_mstr and available pt_mstr
then
   find last pc_mstr where
          pc_list = pr_list
      and pc_prod_line = pt_prod_line
      and trim(pc_part) = ""
      and (pc_start <= eff_date or pc_start = ?)
      and (pc_expire >= eff_date or pc_expire = ?)
      and pc_curr = curr
   no-lock no-error.

/* FIND PRICE LIST FOR PRICE LIST */
if not available pc_mstr
then
   find last pc_mstr where
          pc_list = pr_list
      and trim(pc_prod_line) = ""
      and trim(pc_part) = ""
      and (pc_start <= eff_date or pc_start = ?)
      and (pc_expire >= eff_date or pc_expire = ?)
      and pc_curr = curr
   no-lock no-error.

if available pc_mstr
   and (pc_amt_type = "p"
   or   pc_amt_type = "m"
   or   pc_amt_type = "d")
then
   found = yes.
